package com.qiqv.controller;

import com.qiqv.pojo.User;
import com.qiqv.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("getAllUsers")
    public ModelAndView getAllUsers() throws Exception{
        List<User> allUsers = userService.getAllUsers();
        ModelAndView mav = new ModelAndView();
        mav.addObject("userList",allUsers);
        mav.setViewName("userList");
        return mav;
    }
}
